const jwt = require('jsonwebtoken');
module.exports = () => {
    return async (ctx,next) => {
        let writePath = ['/api/login','/api/registry'];
        if(writePath.includes(ctx.path)){
            await next()
        }else{
            let token = ctx.get('token');
            try{
                let info = jwt.verify(token,'yuekao');
                ctx.info = info;
                await next();
            }catch(e){
                ctx.body = {
                    code:0,
                    msg:e
                }
            }
        }
    }
}